﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SzCourt.Logic.BLL;
using SzCourt.Logic.NBL.DBEntities;

namespace SzCourt.WebSite.cha
{
    public partial class result : System.Web.UI.Page
    {
        private string _ClassName = string.Empty;
        private string _Zhi = string.Empty;
        private string _Password = string.Empty;
        private string _CaseWord = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!this.IsPostBack)
                {
                    getParam();
                    getInfo();
                    GetPartiesList();
                    GetCourtList();
                    GetAlreadyCourtList();
                }
            }
            catch(Exception ex)
            {
                this.divErrormsg.InnerText = ex.Message;
            }
        }

        //获取参数值
        private void getParam()
        {
             this._ClassName = string.IsNullOrEmpty(Request.Form["txtClassName"]) ? "" : Request.Form["txtClassName"];
             this._Zhi = string.IsNullOrEmpty(Request.Form["txtZhi"]) ? "" : Request.Form["txtZhi"];
             this._CaseWord = string.IsNullOrEmpty(Request.Form["txtCaseWord"]) ? "" : Request.Form["txtCaseWord"];
             this._Password = string.IsNullOrEmpty(Request.Form["txtPassword"]) ? "" : Request.Form["txtPassword"];
        }

        /// <summary>
        /// 获取基本信息&结案信息
        /// </summary>
        private void getInfo()
        {
            CaseCondition param = new CaseCondition();
            param.CaseName = "(" + this._ClassName + ")" + this._Zhi + "字第" + this._CaseWord + "号";
            param.QueryPWD = this._Password;
            Case bll = new Case();
            pCaseProgressInfo result = (pCaseProgressInfo)bll.GetCaseInfo(param);

            if (result != null)
            {
                this.tdCaseStatus.InnerHtml = result.CaseStatus;
                this.tdBooker.InnerHtml = result.Booker;
                this.tdCaseSource.InnerHtml = result.CaseSource;
                this.tdCaseName.InnerHtml = result.CaseName;
                this.tdCaseName2.InnerHtml = result.CaseName;
                this.tdCaseWord.InnerHtml = result.CaseWord;
                this.tdCauseOfAction.InnerHtml = result.CauseOfAction;
                this.tdClaims.InnerHtml = result.Claims;
                this.tdEndCauseOfAction.InnerHtml = result.EndCauseOfAction;
                this.tdEndMark.InnerHtml = result.EndMark.GetValueOrDefault().ToString();
                this.tdFilingDate.InnerHtml = result.FilingDate.GetValueOrDefault().ToLongDateString();
                this.tdFinalDate.InnerHtml = result.FinalDate.GetValueOrDefault().ToLongDateString();
                this.tdLimitDate.InnerHtml = result.LimitDate.GetValueOrDefault().ToLongDateString();
                this.tdPutOnRecordPeople.InnerHtml = result.PutOnRecordPeople;
                this.tdSettlement.InnerHtml = result.Settlement;
                this.tdStartingMark.InnerHtml = result.StartingMark.GetValueOrDefault().ToString();
                this.tdStartingMark2.InnerHtml = result.StartingMark.GetValueOrDefault().ToString();
                this.tdStructuredDate.InnerHtml = result.StructuredDate.GetValueOrDefault().ToLongDateString();
                this.tdTheDateTime.InnerHtml = result.TheDateTime.GetValueOrDefault().ToLongDateString();
                this.tdTheDept.InnerHtml = result.TheDept;
                this.tdUndertaker.InnerHtml = result.Undertaker;
                this.tdJudge.InnerHtml = result.Judge;//法官助理(跟案助理）
                this.tdPresidingJudge.InnerHtml = result.PresidingJudge;//合议庭其他组成成员(主审法官)
            }
        }

        /// <summary>
        /// 获取当事人列表
        /// </summary>
        private void GetPartiesList()
        {
            CaseCondition param = new CaseCondition();
            param.CaseName = "(" + this._ClassName + ")" + this._Zhi + "字" + this._CaseWord + "号";
            param.QueryPWD = this._Password;
            Case bll = new Case();
            List<pParties> result = (List<pParties>)bll.GetPartiesList(param);

            if (result != null)
            {
                this.rptPartiesList.DataSource = result;
                this.rptPartiesList.DataBind();
            }
        }

        /// <summary>
        /// 获取排期列表
        /// </summary>
        private void GetCourtList()
        {
            CaseCondition param = new CaseCondition();
            param.CaseName = "(" + this._ClassName + ")" + this._Zhi + "字" + this._CaseWord + "号";
            param.QueryPWD = this._Password;
            Case bll = new Case();
            List<pCaseCourtInfo> result = (List<pCaseCourtInfo>)bll.GetCourtList(param);

            if (result != null)
            {
                this.rptCourtList.DataSource = result;
                this.rptCourtList.DataBind();
            }
        }

        /// <summary>
        /// 获取审理列表
        /// </summary>
        private void GetAlreadyCourtList()
        {
            CaseCondition param = new CaseCondition();
            param.CaseName = "(" + this._ClassName + ")" + this._Zhi + "字" + this._CaseWord + "号";
            param.QueryPWD = this._Password;
            Case bll = new Case();
            List<pCaseCourtInfo> result = (List<pCaseCourtInfo>)bll.GetAlreadyCourtList(param);

            if (result != null)
            {
                this.rptAlreadyCourtList.DataSource = result;
                this.rptAlreadyCourtList.DataBind();
            }
        }

    }
}